﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

namespace ZHDJ.MobileInterface
{
    /// <summary>
    /// UserServiceTest 的摘要说明
    /// </summary> 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService] 
    public class UserServiceTest : System.Web.Services.WebService
    { 
        /// <summary>
        /// 获取通知公告、热点新闻、学习十八大、党员先锋四个类别的资讯
        /// </summary>
        /// <param name="type">必填，1：通知公告，2：热点新闻，3：学习十八大， 4：党员先锋</param>
        /// <param name="page_no">必填</param>
        /// <param name="page_count">必填</param>
        /// <param name="md5Str">签名字符串</param>
        /// <returns></returns>
        [WebMethod]
        public string GetInformationList(string a)
        { 
            try
            {
                PushInformationInParam inparam = new PushInformationInParam();
                inparam.id = "3c05bccc7a4648a9abc40f8b53619b8e";
                inparam.publishTime = "2013-04-01";
                inparam.source = "test";
                inparam.title = "测试测试的";
                inparam.type = "1";
                inparam.url = "http://newparty.gmcc.net/Ms/html/InformationDetail.aspx";
                //?InfoType=1&InfoID=01fc20ed95764b6188a70065daf36220
                string mobielUrl = string.Format("http://172.20.14.115:8080/thdj/pushnotification/pushnotificationAction!push.action?id={0}&publishTime={1}&source={2}&title={3}&type={4}&url={5}",
                    inparam.id, inparam.publishTime, inparam.source, inparam.title, inparam.type, inparam.url);
                PushInformationOutParam result = PushHelper.PushMessage<PushInformationInParam, PushInformationOutParam>(mobielUrl, inparam);

                return SerializeHelper.JsonSerializer<PushInformationOutParam>(result); ;
            }
            catch (Exception ex)
            { 
                return "";
            }
        }
    }


    public class PushInformationInParam
    {
        /// <summary>
        ///	类别	
        /// </summary>
        public string type
        { get; set; }
        /// <summary>
        ///	资讯ID	
        /// </summary>
        public string id
        { get; set; }
        /// <summary>
        ///	资讯标题	
        /// </summary>
        public string title
        { get; set; }
        /// <summary>
        ///	发布时间	
        /// </summary>
        public string publishTime
        { get; set; }
        /// <summary>
        ///	资讯来源	
        /// </summary>
        public string source
        { get; set; }
        /// <summary>
        ///	资讯详情HTML页面地址	
        /// </summary>
        public string url
        { get; set; }
    }

    public class PushInformationOutParam
    {
        public PushInformationOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = "";
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        /// 备用字段,目前值为空
        /// </summary>
        public string data
        { get; set; }
    }
}
